package me.goldze.mvvmhabit.binding.viewadapter.radiogroup;

import android.databinding.BindingAdapter;
import android.support.annotation.IdRes;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class ViewAdapter {
    @BindingAdapter(requireAll = false, value = {"onCheckedChangedCommand"})
    public static void onCheckedChangedCommand(RadioGroup radioGroup, final BindingCommand<String> bindingCommand) {
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            /* class me.goldze.mvvmhabit.binding.viewadapter.radiogroup.ViewAdapter.AnonymousClass1 */

            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                bindingCommand.execute(((RadioButton) group.findViewById(checkedId)).getText().toString());
            }
        });
    }
}
